<template>
  <el-form-item label="频道">
    <el-select
      clearable
      placeholder="请选择频道"
      @change="hChange"
      v-model="channelId"
    >
      <el-option
        v-for="channel in channels"
        :key="channel.id"
        :label="channel.name"
        :value="channel.id"
      ></el-option>
    </el-select>
  </el-form-item>
</template>
<script>
export default {
  name: 'Components',
  data () {
    return {
      channelId: '', // 频道编号
      channels: [] // 频道列表
    }
  },
  created () {
    this.loadChannels()
  },
  methods: {
    hChange (val) {
      this.$emit('input', val)
    },
    async loadChannels () {
      try {
        const res = await this.$axios({
          method: 'GET',
          url: '/mp/v1_0/channels'
        })
        console.log(res);
        // 保存频道列表数据
        this.channels = res.data.data.channels
      } catch (err) {
      }
    }
  }
}
</script>
